<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;

class SystemCity extends Model
{
    use HasFactory;
    use PimpableTrait;

    public $searchable = [
        'city_id',
        'level',
        'area_code',
        "name",
        "merger_name",
        'ing',
        'lat',
    ];

    public $fillable = [
        'city_id',
        'level',
        'parent_id',
        'area_code',
        "name",
        "merger_name",
        'ing',
        'lat'
    ];

    public $sortable = [
        'city_id',
        'level',
        'parent_id',
        'ing',
        'lat',
        'is_show',
    ];
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 分类的子类
     */
    public function children()
    {
        return $this->hasMany(SystemCity::class,'pid','id');
    }
}
